{include file="public/header" /}
<body class="gray-bg">
<form id="editcar" onsubmit="return false;">
<div class="wrapper wrapper-content">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>编辑车辆</h5>
                </div>
                <div class="ibox-content layui-form">
                    <div class="layui-row layui-col-space10 layui-form-item ">

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">车辆名称：</label>
                            <div class="layui-input-block">
                                <input type="text" name="car_name" lay-verify="required" value="{$car.car_name}" class="layui-input" placeholder="车辆名称">
                            </div>
                        </div>

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">分类：</label>
                            <div class="layui-input-block">
                                <select name="car_cate_id" lay-verify="required">
                                    {foreach name="cc" item="vo"}
                                    <option value="{$vo.cc_id}" {$vo.cc_id==$car.car_cate_id?'selected':''}>{$vo.cc_name}</option>
                                    {/foreach}
                                </select>
                            </div>
                        </div>

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">缩略图：</label>
                            <input type="hidden" name="img1" id="lay-img1" lay-verify="image" value="{$car.car_thumb}">
                            <div class="layui-input-block">
                                <div id="lay-upload1">上传图片</div>
                                <blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 10px;">
                                    预览图：
                                    <div class="layui-upload-list" id="lay-list1">
                                        <img class="layui-append-img" src="{$car.car_thumb}" onerror="this.src='/static/admin/images/no_img.jpg'">
                                    </div>
                                </blockquote>
                            </div>
                        </div>

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">新闻资讯：</label>
                            <div class="layui-input-block">
                                <select name="car_news" xm-select="select1" lay-verify="required" xm-select-search="" xm-select-search-type="dl">
                                    {foreach name="new" item="v"}
                                    <option value="{$v.new_id}" {in name="v.new_id" value="$car.car_news"}selected{/in}>{$v.new_title}</option>
                                    {/foreach}
                                </select>
                            </div>
                        </div>

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">价格：</label>
                            <div class="layui-input-block">
                                <input type="text" name="car_price" lay-verify="required" placeholder="价格" class="layui-input" oninput="value=value.replace(/[^\d.]/g,'')" value="{$car.car_price}">
                            </div>
                        </div>

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md10">
                            <label class="layui-form-label">主图</br>（比例4:3）</label>
                            <div class="layui-input-block">
                                <input type="hidden" name="del" id="del2" value="">
                                <input type="hidden" id="hid2" value="{$car.car_images}">
                                <input type="hidden" name="photo" id="photo2" value="{$car.car_images}">
                                <div id="uploader2" class="container-s">
                                    <div class="queueList">
                                        <div class="placeholder">
                                            <div id="filePicker2"></div>
                                            <p>或将照片拖到这里</p>
                                        </div>
                                    </div>
                                    <div class="statusBar" style="display:none;">
                                        <div class="layui-progress layui-progress-big active-s" lay-showpercent="true">
                                            <div class="layui-progress-bar layui-bg-blue" lay-percent="0%">
                                            </div>
                                            <span></span>
                                        </div>
                                        <div class="info"></div>
                                        <div class="btns">
                                            <div id="goPicker2" class="filePicker2"></div>
                                            <div class="uploadBtn">开始上传</div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md10">
                            <label class="layui-form-label">外观图</br>（比例4:3）</label>
                            <div class="layui-input-block">
                                <input type="hidden" name="del" id="del3" value="">
                                <input type="hidden" id="hid3" value="{$car.car_out_images}">
                                <input type="hidden" name="photo3" id="photo3" value="{$car.car_out_images}">
                                <div id="uploader3" class="container-s">
                                    <div class="queueList">
                                        <div class="placeholder">
                                            <div id="filePicker3"></div>
                                            <p>或将照片拖到这里</p>
                                        </div>
                                    </div>
                                    <div class="statusBar" style="display:none;">
                                        <div class="layui-progress layui-progress-big active-s" lay-showpercent="true">
                                            <div class="layui-progress-bar layui-bg-blue" lay-percent="0%">
                                            </div>
                                            <span></span>
                                        </div>
                                        <div class="info"></div>
                                        <div class="btns">
                                            <div id="goPicker3" class="filePicker2"></div>
                                            <div class="uploadBtn">开始上传</div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md10">
                            <label class="layui-form-label">中控图片</br>（比例4:3）</label>
                            <div class="layui-input-block">
                                <input type="hidden" name="del" id="del4" value="">
                                <input type="hidden" id="hid4" value="{$car.car_middle_images}">
                                <input type="hidden" name="photo4" id="photo4" value="{$car.car_middle_images}">
                                <div id="uploader4" class="container-s">
                                    <div class="queueList">
                                        <div class="placeholder">
                                            <div id="filePicker4"></div>
                                            <p>或将照片拖到这里</p>
                                        </div>
                                    </div>
                                    <div class="statusBar" style="display:none;">
                                        <div class="layui-progress layui-progress-big active-s" lay-showpercent="true">
                                            <div class="layui-progress-bar layui-bg-blue" lay-percent="0%">
                                            </div>
                                            <span></span>
                                        </div>
                                        <div class="info"></div>
                                        <div class="btns">
                                            <div id="goPicker4" class="filePicker2"></div>
                                            <div class="uploadBtn">开始上传</div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md10">
                            <label class="layui-form-label">座椅图片</br>（比例4:3）</label>
                            <div class="layui-input-block">
                                <input type="hidden" name="del" id="del5" value="">
                                <input type="hidden" id="hid5" value="{$car.car_chair_images}">
                                <input type="hidden" name="photo5" id="photo5" value="{$car.car_chair_images}">
                                <div id="uploader5" class="container-s">
                                    <div class="queueList">
                                        <div class="placeholder">
                                            <div id="filePicker5"></div>
                                            <p>或将照片拖到这里</p>
                                        </div>
                                    </div>
                                    <div class="statusBar" style="display:none;">
                                        <div class="layui-progress layui-progress-big active-s" lay-showpercent="true">
                                            <div class="layui-progress-bar layui-bg-blue" lay-percent="0%">
                                            </div>
                                            <span></span>
                                        </div>
                                        <div class="info"></div>
                                        <div class="btns">
                                            <div id="goPicker5" class="filePicker2"></div>
                                            <div class="uploadBtn">开始上传</div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md10">
                            <label class="layui-form-label">细节图片</br>（比例4:3）</label>
                            <div class="layui-input-block">
                                <input type="hidden" name="del" id="del6" value="">
                                <input type="hidden" id="hid6" value="{$car.car_detail_images}">
                                <input type="hidden" name="photo6" id="photo6" value="{$car.car_detail_images}">
                                <div id="uploader6" class="container-s">
                                    <div class="queueList">
                                        <div class="placeholder">
                                            <div id="filePicker6"></div>
                                            <p>或将照片拖到这里</p>
                                        </div>
                                    </div>
                                    <div class="statusBar" style="display:none;">
                                        <div class="layui-progress layui-progress-big active-s" lay-showpercent="true">
                                            <div class="layui-progress-bar layui-bg-blue" lay-percent="0%">
                                            </div>
                                            <span></span>
                                        </div>
                                        <div class="info"></div>
                                        <div class="btns">
                                            <div id="goPicker6" class="filePicker2"></div>
                                            <div class="uploadBtn">开始上传</div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md10">
                            <label class="layui-form-label">特点图片</br>（比例4:3）</label>
                            <div class="layui-input-block">
                                <input type="hidden" name="del" id="del7" value="">
                                <input type="hidden" id="hid7" value="{$car.car_special_images}">
                                <input type="hidden" name="photo7" id="photo7" value="{$car.car_special_images}">
                                <div id="uploader7" class="container-s">
                                    <div class="queueList">
                                        <div class="placeholder">
                                            <div id="filePicker7"></div>
                                            <p>或将照片拖到这里</p>
                                        </div>
                                    </div>
                                    <div class="statusBar" style="display:none;">
                                        <div class="layui-progress layui-progress-big active-s" lay-showpercent="true">
                                            <div class="layui-progress-bar layui-bg-blue" lay-percent="0%">
                                            </div>
                                            <span></span>
                                        </div>
                                        <div class="info"></div>
                                        <div class="btns">
                                            <div id="goPicker7" class="filePicker2"></div>
                                            <div class="uploadBtn">开始上传</div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md10">
                            <label class="layui-form-label">车辆长图</label>
                            <div class="layui-input-block">
                                <input type="hidden" name="del" id="del8" value="">
                                <input type="hidden" id="hid8" value="{$car.car_long_images}">
                                <input type="hidden" name="photo8" id="photo8" value="{$car.car_long_images}">
                                <div id="uploader8" class="container-s">
                                    <div class="queueList">
                                        <div class="placeholder">
                                            <div id="filePicker8"></div>
                                            <p>或将照片拖到这里</p>
                                        </div>
                                    </div>
                                    <div class="statusBar" style="display:none;">
                                        <div class="layui-progress layui-progress-big active-s" lay-showpercent="true">
                                            <div class="layui-progress-bar layui-bg-blue" lay-percent="0%">
                                            </div>
                                            <span></span>
                                        </div>
                                        <div class="info"></div>
                                        <div class="btns">
                                            <div id="goPicker8" class="filePicker2"></div>
                                            <div class="uploadBtn">开始上传</div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md10">
                            <label class="layui-form-label">介绍：</label>
                            <div class="layui-input-block" id="LAY_editor" lay-verify="editor">
                                <p>{$car.car_detail}</p>
                            </div>
                        </div>

                        <input type="hidden" value="{$car_id}" name="car_id">
                        <textarea id="car_detail" class="hidden" name="car_detail"></textarea>
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <div class="layui-input-block">
                                <button class="layui-btn" lay-submit="" lay-filter="component-form-element" id="submitt">保存
                                </button>
                                <button class="layui-btn layui-btn-primary" onclick="history.go(-1)">关闭</button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
</form>
{include file="public/footer" /}
<script>
    var n2 = wk.uploads({num:3,type:'png,jpg,jpeg',attr:2,status:'update',url:"{:url('admin/upload/upload')}"})
    var n3 = wk.uploads({num:10,type:'png,jpg,jpeg',attr:3,status:'update',url:"{:url('admin/upload/upload')}"})
    var n4 = wk.uploads({num:10,type:'png,jpg,jpeg',attr:4,status:'update',url:"{:url('admin/upload/upload')}"})
    var n5 = wk.uploads({num:10,type:'png,jpg,jpeg',attr:5,status:'update',url:"{:url('admin/upload/upload')}"})
    var n6 = wk.uploads({num:10,type:'png,jpg,jpeg',attr:6,status:'update',url:"{:url('admin/upload/upload')}"})
    var n7 = wk.uploads({num:10,type:'png,jpg,jpeg',attr:7,status:'update',url:"{:url('admin/upload/upload')}"})
    var n8 = wk.uploads({num:10,type:'png,jpg,jpeg',attr:8,status:'update',url:"{:url('admin/upload/upload')}"})
    function imgDel2(e,obj,hid,del){
        wk.update_del(e,obj,hid,del,n2);
    }
    function imgDel3(e,obj,hid,del){
        wk.update_del(e,obj,hid,del,n3);
    }
    function imgDel4(e,obj,hid,del){
        wk.update_del(e,obj,hid,del,n4);
    }
    function imgDel5(e,obj,hid,del){
        wk.update_del(e,obj,hid,del,n5);
    }
    function imgDel6(e,obj,hid,del){
        wk.update_del(e,obj,hid,del,n6);
    }
    function imgDel7(e,obj,hid,del){
        wk.update_del(e,obj,hid,del,n7);
    }
    function imgDel8(e,obj,hid,del){
        wk.update_del(e,obj,hid,del,n8);
    }
    var editor = wk.wang({elem:'#LAY_editor'});
    wk.uploadImg1({size:5,type:'png,jpg,jpeg',url:"{:url('Upload/upload')}",domain:""});

    layui.use(['form','upload','layedit'], function() {
        var form = layui.form;
        form.verify({
            editor:function(value,item){
                if(editor.txt.html() == '<p><br></p>'){
                    return '请填写内容';
                }
            }
        });
//        form.on('submit(component-form-element)', function (data) {
//            data.field.car_detail = editor.txt.html();
//            $('.layui-btn').addClass('layui-disabled').attr('disabled','disabled');
//            $.ajax({
//                url:"{:url('carEdit')}",
//                type:'post',
//                dataType:'json',
//                data:data.field,
//                success:function(res){
//                    if (res.code == 200) {
//                        wk.success(res.msg,"{:url('Car/carIndex')}")
//                    } else {
//                        wk.error(res.msg,'','$(".layui-btn").removeClass(\'layui-disabled\').removeAttr(\'disabled\');');
//                    }
//                }
//            })
//        });
    });
    $('#submitt').click(function(){
        var car_detail = editor.txt.html();
        $('#car_detail').val(car_detail);
        var form_data = $('#editcar').serialize();
        $('.layui-btn').addClass('layui-disabled').attr('disabled','disabled');
        $.ajax({
            url:"{:url('carEdit')}",
            type:'post',
            dataType:'json',
            data:form_data,
            success:function(res){
                if (res.code == 200) {
                    wk.success(res.msg,"{:url('Car/carIndex')}")
                } else {
                    wk.error(res.msg,'','$(".layui-btn").removeClass(\'layui-disabled\').removeAttr(\'disabled\');');
                }
            }
        });
    });
</script>

</body>
</html>
